using System;
using System.Numerics;
 
namespace Problem_2___Astrological_Digits
{
    class Program
    {
 
        static void Main()
        {
            string InputNumber = Console.ReadLine();
            string cleanString = InputNumber.Replace(".","");
 
            cleanString = cleanString.Replace("-", "");
 
            BigInteger DigitNumber = BigInteger.Parse(cleanString);
 
            BigInteger sum = 0;
 
            loop:
            while (DigitNumber != 0)
            {
                sum += DigitNumber % 10;
                DigitNumber /= 10;
            }
            if (sum > 10)
            {
                DigitNumber = sum;
                sum = 0;
                goto loop;
            }
 
            Console.WriteLine(sum);
 
 
 
             
        }
    }
}